let isRefresh = false
let services = []

function getToken() {
  return new Promise((resolve) => {
    // 在这里写获取token的请求,请求成功之后resolve()
    resolve()
  })
}
export async function refreshTokenAndRequest(response) {
  if (!isRefresh) {
    isRefresh = true
    await getToken()
    services.forEach(cb => cb(response.config))
    services = []
    return uni.$u.http.request(response.config)
  } else {
    return Promise(resolve => {
      services.push(() => {
        resolve(uni.$u.http.request(response.config))
      })
    })
  }
}
